<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Production extends CI_Controller {

	function __construct(){
		parent::__construct();
		$this->load->model('production_model');
		$this->load->model('toolimage_model');
	}
	public function index(){
		$this->show(1);
	}
	public function show($arg=1)
	{
		$id = (int)$this->uri->segment(3);
		$id = $id ? $id : $arg;
		if(!$id) show_error('错误的操作');

		$p = $this->production_model->get_production_byid($id);
		if(!$p) show_error('该商品可能已经被删除');
		$data['p'] = $p;

		//评论
		$this->load->model('comment_model');
		$data['c'] = $this->comment_model->get_comment($id,0,PAGENUM);
		$data['num'] = $this->comment_model->get_comment_num($id);

		//咨询
		$this->load->model('zixun_model');
		$data['z1'] = $this->zixun_model->get_zixun($id,1,0,PAGENUM);

		/*
		$data['z2'] = $this->zixun_model->get_zixun($id,2,0,PAGENUM);
		$data['z3'] = $this->zixun_model->get_zixun($id,3,0,PAGENUM);
		$data['z4'] = $this->zixun_model->get_zixun($id,4,0,PAGENUM);
		$data['z5'] = $this->zixun_model->get_zixun($id,5,0,PAGENUM);
		*/
		$data['num1'] = $this->zixun_model->get_zixun_num($id,1);
		/*
		$data['num2'] = $this->zixun_model->get_zixun_num($id,2);
		$data['num3'] = $this->zixun_model->get_zixun_num($id,3);
		$data['num4'] = $this->zixun_model->get_zixun_num($id,4);
		$data['num5'] = $this->zixun_model->get_zixun_num($id,5);
		*/
		
		$this->load->model('rese_model');
		$data['rese'] = $rese = $this->rese_model->get_rese_bypid($id);
		if($rese){
			foreach($rese as $rs){
				switch($rs->type){
					case 'zf':$data['zf'] = $rs;break;
					case 'ps':$data['ps'] = $rs;break;
					case 'ss':$data['ss'] = $rs;break;
					case 'cj':$data['cj'] = $rs;break;
				}
			}
		}
		//topic
		$this->load->model('topic_model');
		$data['topic'] = $this->topic_model->get_topic($id,0,PAGENUM);
		$data['topic_num'] =  $this->topic_model->get_topic_num($id);

		//最新动态
		$this->load->model('news_model');
		$data['news'] = $this->news_model->get_news(0,PAGENUM,true);

		//专业知识
		$this->load->model('know_model');
		$data['know'] = $this->know_model->get_know(0,PAGENUM,true);
		$this->load->view('production.tpl',$data);
	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */